package com.yfp.machine.service.impl;

import com.yfp.machine.domain.VersionPushRecord;
import com.yfp.machine.mapper.VersionPushRecordMapper;
import com.yfp.machine.service.VersionPushRecordService;
import jakarta.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;



/**
 * 版本推送记录表(VersionPushRecord)表服务实现类
 *
 *
 * @since 2023-12-16 21:36:37
 */
@Service("versionPushRecordService")
public class VersionPushRecordServiceImpl implements VersionPushRecordService {
    @Resource
    private VersionPushRecordMapper versionPushRecordMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param recordNo 主键
     * @return 实例对象
     */
    @Override
    public VersionPushRecord queryById(String recordNo) {
        return this.versionPushRecordMapper.queryById(recordNo);
    }

    /**
     * 分页查询
     *
     * @param versionPushRecord 筛选条件
     * @param pageRequest       分页对象
     * @return 查询结果
     */
    @Override
    public Page<VersionPushRecord> queryByPage(VersionPushRecord versionPushRecord, PageRequest pageRequest) {
        long total = this.versionPushRecordMapper.count(versionPushRecord);
        return new PageImpl<>(this.versionPushRecordMapper.queryAllByLimit(versionPushRecord, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param versionPushRecord 实例对象
     * @return 实例对象
     */
    @Override
    public VersionPushRecord insert(VersionPushRecord versionPushRecord) {
        this.versionPushRecordMapper.insert(versionPushRecord);
        return versionPushRecord;
    }

    /**
     * 修改数据
     *
     * @param versionPushRecord 实例对象
     * @return 实例对象
     */
    @Override
    public VersionPushRecord update(VersionPushRecord versionPushRecord) {
        this.versionPushRecordMapper.update(versionPushRecord);
        return this.queryById(versionPushRecord.getRecordNo());
    }

    /**
     * 通过主键删除数据
     *
     * @param recordNo 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String recordNo) {
        return this.versionPushRecordMapper.deleteById(recordNo) > 0;
    }
}
